<!--
* @description  
* @fileName  3_组件的嵌套
* @author zhoujunlin
* @date 2022-04-18 20:10:16
* @version V1.0.0
!-->

<!-- 

 -->

<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>3_组件的嵌套</title>
    <script src="../js/vue.js"></script>
</head>

<body>
    <div id="app">

    </div>
</body>
<script type="text/javascript">
    Vue.config.productionTip = false
    // 第一步：创建student组件
    const student = Vue.extend({
        name: 'student',
        template: `
            <div>
                <h2>学生姓名：{{name}}</h2>
                <h2>学生年龄：{{age}}</h2>
            </div>
        `,
        data() {
            return {
                name: '张三',
                age: 18
            }
        }
    })

    // 第一步：创建school组件
    const school = Vue.extend({
        name: 'school',
        template: `
            <div>
                <h2>学校名称：{{name}}</h2>
                <h2>学校地址：{{address}}</h2>
                <student></student>
            </div>
        `,
        data() {
            return {
                name: '尚硅谷',
                address: '北京昌平'
            }
        },
        components: {
            student
        }
    })

    // 第一步：创建hello组件
    const hello = Vue.extend({
        template: `
            <h1>{{msg}}</h1>
        `,
        data() {
            return {
                msg: '热烈欢迎'
            }
        }
    })

    // 第一步：创建app组件作为顶层
    const app = Vue.extend({
        template: `
            <div>
                <hello></hello>
                <school></school>
            </div>
        `,
        components: { hello, school }
    })

    var vm = new Vue({
        el: '#app',
        template: '<app></app>',
        components: {
            app
        }
    });

</script>

</html>